package com.humble.vichatbackend.config;

import com.humble.vichatbackend.interceptor.UserInterceptor;
import com.humble.vichatbackend.interceptor.WebSocketInterceptor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;

@Configuration
@Slf4j
public class HandlerConfig implements WebMvcConfigurer {
    @Override
    public void addInterceptors(InterceptorRegistry registry) {
        //注册拦截器的顺序就是执行顺序
        registry.addInterceptor(new UserInterceptor())
                .addPathPatterns("api/user/**","/api/team/**") // 添加拦截路径
                .excludePathPatterns("/api/error", "/api/user/login", "/api/swagger-ui/index.html"); // 排除拦截路径
        registry.addInterceptor(new WebSocketInterceptor())
                .addPathPatterns("/api/chat/**");
    }

}
